home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-12-31 | 54.9 KB | 1,503 lines | [TEXT/R*ch] |
- C.S.M.P. Digest Tue, 31 Oct 95 Volume 3 : Issue 119
-
- Today's Topics:
-
- I've hit a brick wall!
- Implementing Command-. and Escape for cancel in dialogue
- PPC ProcPtr functions?
- Perl for Mac?
- Popup Menus in 9-pt geneva ?????
- Q: using OSAExecute to singlestep AppleScript
- Reading Notification Manager queue?
-
-
-
- The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
- (pottier@clipper.ens.fr).
-
- The digest is a collection of article threads from the internet newsgroups
- comp.sys.mac.programmer.help, csmp.tools and csmp.misc. It is designed for
- people who read news semi-regularly and want an archive of the discussions.
- If you don't know what a newsgroup is, you probably don't have access to
- it. Ask your systems administrator(s) for details. If you don't have access
- to news, you may still be able to post messages to the group by using a
- mail server like anon.penet.fi (mail help@anon.penet.fi for more
- information).
-
- Each issue of the digest contains one or more sets of articles (called
- threads), with each set corresponding to a 'discussion' of a particular
- subject. The articles are not edited; all articles included in this digest
- are in their original posted form (as received by our news server at
- nef.ens.fr). Article threads are not added to the digest until the last
- article added to the thread is at least two weeks old (this is to ensure that
- the thread is dead before adding it to the digest). Article threads that
- consist of only one message are generally not included in the digest.
-
- The digest is officially distributed by two means, by email and ftp.
-
- If you want to receive the digest by mail, send email to listserv@ens.fr
- with no subject and one of the following commands as body:
- help Sends you a summary of commands
- subscribe csmp-digest Your Name Adds you to the mailing list
- signoff csmp-digest Removes you from the list
- Once you have subscribed, you will automatically receive each new
- issue as it is created.
-
- The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
- Questions related to the ftp site should be directed to
- scott.silver@dartmouth.edu.
-
- -------------------------------------------------------
-
- >From Keith Wiley <keithw@wam.umd.edu>
- Subject: I've hit a brick wall!
- Date: Mon, 2 Oct 1995 23:01:19 -0400
- Organization: University of Maryland College Park
-
- Ok, I can't continue until I learn how to segment my project because I've
- hit the 32K limit. I posted some questions earlier and got several
- responses, thank you. However, I still have some major problems.
-
- Aside from making header files, (I gave up on that temporarily), I'm just
- trying to put a full copy of all #define, #include, typedefs, and globals
- at the top of each .c source file. It seems to work except that I get
- link errors complaining about multidefined global variables. If I
- eliminate the declarations from all but one file then I get undeclared
- errors (of course). I can't figure out how to get around this. I'm
- putting extern in all the declarations. I've tried putting extern in all
- files except the one with main(). I've tried everything. What do I need
- to do?
-
- Also, what's up with making header files?
-
- . . .. ... ..... ........ ............. .....................
- .. ... ..... ....... ........... ............. .................
- . .. .... ........ ................ ................................
- Keith Wiley, Electrogenetic Engineer *
- University of Maryland at College Park * * * * * *
- email: keithw@wam.umd.edu *** ** * * ** *
- world wide web: http://www.wam.umd.edu/~keithw * ** ** ***
-
-
- +++++++++++++++++++++++++++
-
- >From albtrssp@crocker.com (Kevin Tieskoetter)
- Date: 3 Oct 1995 01:31:53 GMT
- Organization: Albatross Productions
-
- In article <Pine.ULT.3.91.951002225623.27668A-100000@rac5.wam.umd.edu>
- Keith Wiley <keithw@wam.umd.edu> writes:
-
- > Aside from making header files, (I gave up on that temporarily), I'm just
- > trying to put a full copy of all #define, #include, typedefs, and globals
- > at the top of each .c source file. It seems to work except that I get
- > link errors complaining about multidefined global variables. If I
- > eliminate the declarations from all but one file then I get undeclared
- > errors (of course). I can't figure out how to get around this. I'm
- > putting extern in all the declarations. I've tried putting extern in all
- > files except the one with main(). I've tried everything. What do I need
- > to do?
-
- You can't give up on making header files - they're unavoidable.
-
- A header file's purpose is to contain:
-
- a) a prototype of all of the functions in the .c file that you want
- other files to have access to
- b) any #defines, typedefs that are related to the .c file, but you want
- to have access to in any other files
- c) >>>extern<<< declarations for globals that are in the .c file that
- you want other files to have access to (I'll explain in a moment)
-
- Notice that the common thread between the a, b, and c is that the
- header file is for things that you want other files to have access to.
- If you have a typedef structure in one .c file that you don't need to
- use in any other file, don't put it into the header file (well, you
- can, but it's good practice not to). Likewise, if you have a structure
- that you need to use in more than one .c file, put it in a header file,
- and include that header in each .c file that needs the structure.
-
- If you're not familiar with prototypes, they are statements that tell
- the compiler how a particular function is called. If you open up any
- Macintosh header file (Dialogs.h for example), you'll find tons of
- prototypes. Protypes are simple. If your function looks like this:
-
- short MyFunction(short myInput)
- {
- ....code.....
- return myShort;
- }
-
- Your prototype would look like this:
-
- short MyFunction(short myInput);
-
-
- Essentially, it's the declaration of the function, with a semicolon (;)
- after it. Prototypes are a wonderful thing - they allow the compiler to
- make sure you're calling your functions correctly and eliminate lots of
- errors later in the process. I recommend that you change your compiler
- settings to "Require Function Prototypes" and that you NEVER turn it
- off.
-
- Now, globals. You ONLY want to define globals inside .c files. As you
- probably know, globals are defined like this:
-
-
- short gMyGlobalVariable;
-
- When the compiler encounters this, it says "Oh, I need to allocate
- space inside the code for this variable named "gMyGlobalVariable". If
- you were to put this global inside a .h file, you would be telling the
- compiler to allocate space for the variable every time it encountered
- the declaration. Since this is obviously an error, the compiler won't
- let you declare globals with the same name more than once (static
- globals are an exception, but you don't need to worry about those yet).
-
- But your other files may also need access to the same global. The
- solution is to declare a sort of "prototype" for the global, which is
- called an "extern". It is done like this:
-
- extern short gMyGlobalVariable;
-
- When the compiler encounters an extern global, it just says to itself
- that "oh, gMyGlobalVariable must be defined some other place; I'll let
- the code compiler, and I'll figure it out later".
-
- When you declare a global that needs to be used in more than one file,
- you need to declare both the global itself (in the .c file) AND the
- "extern" global (in the corresponding .h file).
-
-
- Then, at the top of each of your .c files, figure out which of the .h
- files you need to include to get it to work correctly, and add those
- #include statements.
-
-
- You CANNOT get by in C without using .h files!
-
-
- Good luck!
-
-
- -kevin
-
- //---------------------------------------------------------------------
- Kevin Tieskoetter / Software Prestidigitator, Specular International
- //---------------------------------------------------------------------
-
- +++++++++++++++++++++++++++
-
- >From kenlong@netcom.com (Ken Long)
- Date: Tue, 3 Oct 1995 07:24:49 GMT
- Organization: NETCOM On-line Communication Services (408 261-4700 guest)
-
- Keith Wiley (keithw@wam.umd.edu) wrote:
- : Ok, I can't continue until I learn how to segment my project because I've
- : hit the 32K limit. I posted some questions earlier and got several
- : responses, thank you. However, I still have some major problems.
-
- In Think C 5, if you had a segment that was too big, it would just tell
- you as a link error. In Think C 7 it asks if you'd like your project
- automatically segmented.
-
- : Aside from making header files, (I gave up on that temporarily), I'm just
- : trying to put a full copy of all #define, #include, typedefs, and globals
- : at the top of each .c source file. It seems to work except that I get
- : link errors complaining about multidefined global variables.
-
- I try to simplify any projects I download, by putting all the source and
- header data all in one file. Strive for simplification anywhere possible.
- If a set of headers and source files merged end up being less than about
- 90K it usually works fine.
-
- All a header is, really, is a setup for that which is remaining. Like a
- newspaper headline is a header for the article. The headboard of a bed
- is nearest the head. If you head your boat into the wind, the head (bow)
- goes into the wind first.
-
- Defines can go in one header file and be included by all files, as far as
- I've seen, and give no errors. Same with typedefs. Global variables
- MUST be delcared only once, in one file. You do not need to "#include"
- that file in any other file. You merely make the declaration in the
- other files that use the global variables *except* you put the keyword
- "extern' infront of it.
-
- Example:
-
- In main.c, you say "short thisShort;" and, in events.c, *if* it uses that
- variable, you say "extern short thisShort;" - it's that simple.
-
- If you make a "MyProg.h" file and put "short thisShort;" in it and in both
- main.c and event.c you say "#include "MyProg.h"" you will get a multiply
- defined error on "thisShort"
-
- : If I
- : eliminate the declarations from all but one file then I get undeclared
- : errors (of course). I can't figure out how to get around this. I'm
- : putting extern in all the declarations. I've tried putting extern in all
- : files except the one with main(). I've tried everything. What do I need
- : to do?
-
- If you put "extern" in front of *all* declarations, then it looks for the
- declaration externally and doesn't find it because it's referred to an
- external declaration every time.
-
- The rule of thumb is: "Declare the global in the first file it's used
- in, then declare it "extern" in any *subsequent* files it's used in."
-
- Like this:
-
- // FileOne.c
-
- short thisIsADeclaration;
-
- TheFunctionAtTheJunction ()
- {
- thisIsADeclaration = 1;
-
- DoBackFlips (thisIsADeclaration);
- }
- // end of file.
-
- //FileTwo.c
-
- extern short thisIsADeclaration;
-
- FunctionThatsMunchin ()
- {
- thisIsADeclaration = 4;
-
- DanceTheBooGaLoo (thisIsADeclaration);
- }
- //end of file.
-
- This stuff is in the manual. RTFM! This is not stuff than can be, or
- needs to be "figured out." It needs to be read and understood and SEEN.
- Look at example source project. SEE how they are. Read up on the layout
- and operation of the programming environment you are using and the C
- programming language if need be.
-
- If you don't have a manual, write to the publisher and see about getting
- one. All header files do is define things that would normally be defined
- IN the source file where what's defined is *used*.
-
- If you open a source file which has headers included and select
- "Preprocess" from the appropriate menu, it will make a new file where all
- the definitions and source are contained within it. No header files
- needed because everything that file uses is defined right in it. #defines
- are "eaten" and what was #defined before is replaced by what it was
- #defined as. In other words, the code is "washed" in preparation to
- compiling.
-
- Headers (predefinition/declaration before use) are needed, but header
- files are not needed. They are ONLY for convenience of the programmer.
- They save him typing, copying and pasting and make his source file nice
- and neat.
-
- Open a project where a .c file has a #include... Now open that header
- and select all and copy, then close it. Now select the line in the
- source that said "#include "ThatHeader.h" and paste. The include line
- will be replaced by that which was included. It's included internally,
- now. That's the only difference. You don't have to say to include it
- because it's already included.
-
- -Ken-
-
- +++++++++++++++++++++++++++
-
- >From carl.gustafson@ece.drexel.edu (Carl Gustafson)
- Date: 3 Oct 1995 11:57:59 GMT
- Organization: Imaging and Computer Vision Center, Drexel University
-
- In article <Pine.ULT.3.91.951002225623.27668A-100000@rac5.wam.umd.edu>,
- Keith Wiley <keithw@wam.umd.edu> wrote:
-
- > Ok, I can't continue until I learn how to segment my project because I've
- > hit the 32K limit. I posted some questions earlier and got several
- > responses, thank you. However, I still have some major problems.
- >
- > Aside from making header files, (I gave up on that temporarily), I'm just
- > trying to put a full copy of all #define, #include, typedefs, and globals
- > at the top of each .c source file. It seems to work except that I get
- > link errors complaining about multidefined global variables. If I
- > eliminate the declarations from all but one file then I get undeclared
- > errors (of course). I can't figure out how to get around this. I'm
- > putting extern in all the declarations. I've tried putting extern in all
- > files except the one with main(). I've tried everything. What do I need
- > to do?
- >
- > Also, what's up with making header files?
-
- What you need to do is face Cupertino, genuflect, and repeat three times:
- I'll try harder next time...
-
- Actually, splitting your code into separate files to make separate
- segments is implementation dependent. (Think C and it's relatives) In
- other environments (MPW) you would use #pragma segment directives.
-
- That said, you could also configure your compiler and linker to do a
- "model far" or "big link" build, where you have branch islands in the
- linked code, so that nothing is more than a 16-bit pc-relative jump away,
- allowing virtually unlimited code size. PPC-native apps don't use segments
- (or, as I say to my Intel-Inside buddies, segments are for worms.) Again,
- environment dependent.
-
- Header files should contain declarations (definitions? I never keep the
- names straight) for only the externally visible entities in the associated
- source code file. If your source file refers to a name defined [<= there,
- that must be it!] in another source file, you #include the header file for
- that source file.
-
- --
- Carl Gustafson
- Imaging and Computer Vision Center
- Drexel University, Philadelphia, Penna
- - ----------------------------------------------------------
- I don't speak for Drexel, and Drexel doesn't listen to me...
-
- +++++++++++++++++++++++++++
-
- >From sample@esltd.com (Don Sample)
- Date: Wed, 04 Oct 1995 15:53:31 -0400
- Organization: Enterprise Solutions Ltd
-
- In article <Pine.ULT.3.91.951002225623.27668A-100000@rac5.wam.umd.edu>,
- Keith Wiley <keithw@wam.umd.edu> wrote:
-
- > Ok, I can't continue until I learn how to segment my project because I've
- > hit the 32K limit. I posted some questions earlier and got several
- > responses, thank you. However, I still have some major problems.
- >
- > Aside from making header files, (I gave up on that temporarily), I'm just
- > trying to put a full copy of all #define, #include, typedefs, and globals
- > at the top of each .c source file. It seems to work except that I get
- > link errors complaining about multidefined global variables. If I
- > eliminate the declarations from all but one file then I get undeclared
- > errors (of course). I can't figure out how to get around this. I'm
- > putting extern in all the declarations. I've tried putting extern in all
- > files except the one with main(). I've tried everything. What do I need
- > to do?
- >
- > Also, what's up with making header files?
- >
- How you segment a program depends on what your development environment.
- In MPW you use #pragma statements to tell the compiler/linker which
- segment to put functions into. In the Symantec and Metrowerks IDEs you
- can move a file to a different segment by dragging it in the project
- window. To create a new segment simply drag it down below the bottom
- 'totals' line in the project window.
-
-
- A header file is simply a text file. You can put anything into it that
- you can put into a C source file. By convention header file names have
- the sufix ".h" but they don't have to, you can use any valid file name.
- Generally you put information into them which is shared between source
- files (#defines, typedefs, function prototypes, etc.)
-
- To include a header file in your source you use the #include statement.
- For example if you have created a header file named "MyHeader.h" you would
- include it using the statement:
-
- #include "MyHeader.h"
-
- I suspect that you are trying to do something like "#include <MyHeader.h>"
- and the compiler is telling you that it can't find the file. The angle
- brackets around a file name tell the compiler to look in a specific set of
- directories for the header file. Generally you only use them when
- including files which came with the compiler. For your own header files
- use the quotes, which will search the directories containing your source
- code for the header files. (Exactly where the compiler looks for header
- files depends on your development environment, but a good general rule of
- thumb is that if you wrote the header file use "", and if it came with the
- compiler use <>.)
-
- +++++++++++++++++++++++++++
-
- >From urrostro@uxa.ecn.bgu.edu (Richard Rostrom)
- Date: 12 Oct 1995 04:05:46 GMT
- Organization: Educational Computing Network
-
- Don Sample (sample@esltd.com) wrote:
- : In article <Pine.ULT.3.91.951002225623.27668A-100000@rac5.wam.umd.edu>,
- : Keith Wiley <keithw@wam.umd.edu> wrote:
-
- : > Aside from making header files, (I gave up on that temporarily), I'm just
- : > trying to put a full copy of all #define, #include, typedefs, and globals
- : > at the top of each .c source file. It seems to work except that I get
- : > link errors complaining about multidefined global variables. If I
- : > eliminate the declarations from all but one file then I get undeclared
- : > errors (of course). I can't figure out how to get around this.
-
- declare the global variables in one file. Put extern declarations of
- those variables in each of your other files.
- To simplify your life, use an include file for the extern declarations,
- so that all modules will use the same set of declarations.
-
- This should be done for all typedefs and structs as well.
-
- These should be two different files, BTW, as you don't want to include
- the externs in the file where the globals are defined!
-
- +++++++++++++++++++++++++++
-
- >From skevill@tartarus.uwa.edu.au (Scott Kevill)
- Date: Sat, 14 Oct 1995 11:35:52 +0800
- Organization: The University of Western Australia
-
- In article <45i46q$b0e@news.ecn.bgu.edu>, urrostro@uxa.ecn.bgu.edu
- (Richard Rostrom) wrote:
-
- : Don Sample (sample@esltd.com) wrote:
- : : In article <Pine.ULT.3.91.951002225623.27668A-100000@rac5.wam.umd.edu>,
- : : Keith Wiley <keithw@wam.umd.edu> wrote:
- :
- : : > Aside from making header files, (I gave up on that temporarily), I'm just
- : : > trying to put a full copy of all #define, #include, typedefs, and globals
- : : > at the top of each .c source file. It seems to work except that I get
- : : > link errors complaining about multidefined global variables. If I
- : : > eliminate the declarations from all but one file then I get undeclared
- : : > errors (of course). I can't figure out how to get around this.
- :
- : declare the global variables in one file. Put extern declarations of
- : those variables in each of your other files.
- :
- : To simplify your life, use an include file for the extern declarations,
- : so that all modules will use the same set of declarations.
- :
- : This should be done for all typedefs and structs as well.
- :
- : These should be two different files, BTW, as you don't want to include
- : the externs in the file where the globals are defined!
-
- I don't know if it's good practice or not, but something I've done to make
- this easier goes like this:
-
- //-----------------------------
- // Globals.h
- #ifdef __MAIN__
- #define extern
- #endif
-
- extern int a, b, c;
- extern char d, e, f;
-
- #undef extern
- //-----------------------------
- // Main.c
- #define __MAIN__
- #include "Globals.h"
- ....
- //-----------------------------
- // OtherFile.c
- #include "Globals.h"
- ....
-
- It's a bit of a kludge I guess, but it means only one copy of the globals
- that I have to update each time. It could be bad that every file gets all
- the globals instead of just the ones it needs.
-
- Comments are welcome!
-
- Scott Kevill.
- skevill@tartarus.uwa.edu.au
-
- +++++++++++++++++++++++++++
-
- >From sample@esltd.com (Don Sample)
- Date: Mon, 16 Oct 1995 13:52:21 -0400
- Organization: Enterprise Solutions Ltd
-
- In article <skevill-1410951135520001@s187.dialup.uwa.edu.au>,
- skevill@tartarus.uwa.edu.au (Scott Kevill) wrote:
-
- >
- > I don't know if it's good practice or not, but something I've done to make
- > this easier goes like this:
- >
- > //-----------------------------
- > // Globals.h
- > #ifdef __MAIN__
- > #define extern
- > #endif
- >
- > extern int a, b, c;
- > extern char d, e, f;
- >
- > #undef extern
- > //-----------------------------
- > // Main.c
- > #define __MAIN__
- > #include "Globals.h"
- > ....
- > //-----------------------------
- > // OtherFile.c
- > #include "Globals.h"
- > ....
- >
- > It's a bit of a kludge I guess, but it means only one copy of the globals
- > that I have to update each time. It could be bad that every file gets all
- > the globals instead of just the ones it needs.
- >
- > Comments are welcome!
- >
-
- Except for 'extern' being a reserved word which I don't think many
- compilers will let you redefine, I've seen this general technique used by
- a lot of people, usually something like:
-
- #ifndef __MAIN__
- #define EXTERN extern
- #else
- #define EXTERN
- #endif
-
- EXTERN int a, b, c;
-
- ---------------------------
-
- >From cwatson@cam.org (Chris Watson)
- Subject: Implementing Command-. and Escape for cancel in dialogue
- Date: Tue, 03 Oct 1995 12:32:24 -0400
- Organization: Communications Accessibles Montreal, Quebec Canada
-
- I have a movable modal dialogue and would like to implement the Command-.
- and escape keys to click the cancel button. In modal dialogues, I use
- SetDialogCancelItem () but this does not seem to work in movable modal
- dialgues.
-
- I know I have to check the keyDown event and all that, my question is
- whether to check the charcode or the keycode and how specifically to do
- that given a keyDown event. I don't know what the values for the escape
- and '.' are either.
-
- Thanks for any help!
-
-
- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
- H H | | |
- | | | Sean McBride | |
- H-C-C-O-H | cwatson@cam.org | "Total destructive interference" |
- | | | Montreal, Canada | |
- H H | | |
- <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
- +++++++++++++++++++++++++++
-
- >From technic@seanet.com (Ronald N. Tjoelker)
- Date: Tue, 03 Oct 1995 15:07:41 -0700
- Organization: Seanet Online Services, Seattle WA
-
- In article <cwatson-0310951232240001@cwatson.hip.cam.org>, cwatson@cam.org
- (Chris Watson) wrote:
-
- > I have a movable modal dialogue and would like to implement the Command-.
- > and escape keys to click the cancel button. In modal dialogues, I use
- > SetDialogCancelItem () but this does not seem to work in movable modal
- > dialgues.
- >
- > I know I have to check the keyDown event and all that, my question is
- > whether to check the charcode or the keycode and how specifically to do
- > that given a keyDown event. I don't know what the values for the escape
- > and '.' are either.
-
-
- if (event.what == keyDown)
- {
- c = (event.message & charCodeMask);
-
- if (c == 13 || c == 3) /* return or enter */
- {
- done = true;
- }
- if ((c == '.' && event.modifiers & cmdKey) || c == 27) /* cmd . or esc */
- {
- done = true;
- }
- }
-
- +++++++++++++++++++++++++++
-
- >From erichsen@pacificnet.net (Erichsen)
- Date: Tue, 03 Oct 1995 18:18:13 -0700
- Organization: Disorganized
-
- In article <technic-0310951507410001@technic.seanet.com>,
- technic@seanet.com (Ronald N. Tjoelker) wrote:
-
- > if ((c == '.' && event.modifiers & cmdKey) || c == 27) /* cmd . or esc */
-
- When checking for a command-period, you should make sure it will also work
- on keyboards that require a cmd-shift to get to the period. There's a
- tech-note and some code that shows how to do it.
-
- +++++++++++++++++++++++++++
-
- >From cwatson@cam.org (Chris Watson)
- Date: Tue, 03 Oct 1995 22:07:20 -0400
- Organization: Communications Accessibles Montreal, Quebec Canada
-
- In article <technic-0310951507410001@technic.seanet.com>,
- technic@seanet.com (Ronald N. Tjoelker) wrote:
-
- >> I have a movable modal dialogue and would like to implement the Command-.
- >> and escape keys to click the cancel button.
- >> I know I have to check the keyDown event and all that, my question is
- >> whether to check the charcode or the keycode and how specifically to do
- >> that given a keyDown event.
- >
- > c = (event.message & charCodeMask);
- >
- > if (c == 13 || c == 3) /* return or enter */
- > done = true;
- > if ((c == '.' && event.modifiers & cmdKey) || c == 27)
- > done = true;
-
- Perhaps my orignal post was not as clear as I had intended. This isn't
- really a programming problem as much as a question of Mac human interface
- guidelines.
-
- If I was to use the code you suggested a few issues are raised who's
- answers I'm not sure of.
-
- First of all, does the state of the command key matter when testing the
- escape key? Should Command-Escape also click cancel?
-
- Next, if I use this code checking for a keypress with charCode == 27, then
- pressing the 'clear' key on the keypad will also click cancel, since
- escape and clear have the same char code. Should I be checking the
- keyCode instead of the charCode?
-
- Next, how about the period key? Should the one on the keypad also be
- allowed? If the user has set in the Numbers control panel that the
- decimal character be a ',' (comma) instead of a period should pressing the
- keypad 'period' also work? Again, should I be checking for a keyCode or a
- charCode?
-
- Lastly, if I do need to check the keyCode, how do I do this? (this is a
- programming problem). I know the charCode is event->message &
- charCodeMask, how do I extract the keyCode from the event? event->message
- & keyCodeMask does not provide the correct value.
-
- I hope this clears up what I mean... Thanks for any help!!
-
- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
- H H | | |
- | | | Chris Watson | |
- H-C-C-O-H | cwatson@cam.org | "Total destructive interference" |
- | | | Montreal, Canada | |
- H H | | |
- <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
- +++++++++++++++++++++++++++
-
- >From Francois-Regis.Degott@imag.fr (F. Degott)
- Date: 4 Oct 1995 13:46:49 GMT
- Organization: LMC-IMAG Grenoble France
-
- In article <cwatson-0310952207200001@cwatson.hip.cam.org>, cwatson@cam.org
- (Chris Watson) wrote:
-
- >[cut]
- >Lastly, if I do need to check the keyCode, how do I do this? (this is a
- >programming problem). I know the charCode is event->message &
- >charCodeMask, how do I extract the keyCode from the event? event->message
- >& keyCodeMask does not provide the correct value.
- >
- >I hope this clears up what I mean... Thanks for any help!!
- >
-
- Hi Chris,
-
- to get the charCode and the keyCode of the event.message field:
-
- Pascal:
- charCode:= char(BitAnd(event.message, charCodeMask));
- keyCode:= BitAnd(event.message, keyCodeMask) div 256;
-
- C:
- charCode = (char)(event.message & charCodeMask);
- keyCode = (event.message & keyCodeMask) / 256; {or >>8}
-
- keyCode for <escape key> = $35 (53 decimal)
- charCode for <escape key> = $1B (27 decimal)
-
- HTH
- Fr
- ___________________________________________________________________________
- FR Degott (Francois-Regis.Degott@imag.fr)
- LogiMath, Lab. LMC-IMAG - Grenoble - France
-
- +++++++++++++++++++++++++++
-
- >From stk@berlin.snafu.de (Stefan Kurth)
- Date: Wed, 04 Oct 1995 18:11:56 +0100
- Organization: none
-
- Chris Watson <cwatson@cam.org> wrote:
-
- > I have a movable modal dialogue and would like to implement the Command-.
- > and escape keys to click the cancel button. In modal dialogues, I use
- > SetDialogCancelItem () but this does not seem to work in movable modal
- > dialgues.
-
- It does work in movable modal dialogs. All you have to do is call the
- standard filter proc. (GetStdFilterProc)
-
-
- --
- Stefan Kurth
- Berlin, Germany
-
- +++++++++++++++++++++++++++
-
- >From rdwells@mmm.com (Richard Wells)
- Date: 4 Oct 1995 23:14:00 GMT
- Organization: 3M Company
-
- cwatson@cam.org (Chris Watson) wrote:
- >First of all, does the state of the command key matter when testing the
- >escape key? Should Command-Escape also click cancel?
- >
- >Next, if I use this code checking for a keypress with charCode == 27, then
- >pressing the 'clear' key on the keypad will also click cancel, since
- >escape and clear have the same char code. Should I be checking the
- >keyCode instead of the charCode?
- >
- >Next, how about the period key? Should the one on the keypad also be
- >allowed? If the user has set in the Numbers control panel that the
- >decimal character be a ',' (comma) instead of a period should pressing the
- >keypad 'period' also work? Again, should I be checking for a keyCode or a
- >charCode?
- >
- >Lastly, if I do need to check the keyCode, how do I do this? (this is a
- >programming problem). I know the charCode is event->message &
- >charCodeMask, how do I extract the keyCode from the event? event->message
- >& keyCodeMask does not provide the correct value.
-
- One more example: try typing control-c when a dialog is displayed. Most
- applications treat this the same as the enter key, and act as if the
- OK button was hit. Of course, if your users are former DOS types, where
- control-c meant cancel, this is rather counter-intuitive.
-
- BTW: (event->message & keyCodeMask) >> 8 will give you the key code.
-
-
-
- +++++++++++++++++++++++++++
-
- >From cwatson@cam.org (Sean McBride)
- Date: Wed, 11 Oct 1995 19:40:19 -0400
- Organization: Communications Accessibles Montreal, Quebec Canada
-
- In article <44v4fo$50g@dawn.mmm.com>, rdwells@mmm.com (Richard Wells) wrote:
-
- >One more example: try typing control-c when a dialog is displayed. Most
- >applications treat this the same as the enter key, and act as if the
- >OK button was hit. Of course, if your users are former DOS types, where
- >control-c meant cancel, this is rather counter-intuitive.
-
- That's an interesting point, but control-c produces the ascii character
- for the enter key (keypad) and I've found every other application allows
- this to me used.
-
- Also, isn't it alt-c that cancels with dos, not control-c, since ascii is
- used with dos also?
-
- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
- H H | | |
- | | | Sean McBride | |
- H-C-C-O-H | cwatson@cam.org | "Total destructive interference" |
- | | | Montreal, Canada | "For Unlawful Carnal Knowledge" |
- H H | | |
- <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
- +++++++++++++++++++++++++++
-
- >From rdwells@mmm.com (Richard Wells)
- Date: 12 Oct 1995 19:09:16 GMT
- Organization: 3M - St. Paul, MN 55144-1000 US
-
- cwatson@cam.org (Sean McBride) wrote:
- >In article <44v4fo$50g@dawn.mmm.com>, rdwells@mmm.com (Richard Wells) wrote:
- >
- >>One more example: try typing control-c when a dialog is displayed. Most
- >>applications treat this the same as the enter key, and act as if the
- >>OK button was hit. Of course, if your users are former DOS types, where
- >>control-c meant cancel, this is rather counter-intuitive.
- >
- >That's an interesting point, but control-c produces the ascii character
- >for the enter key (keypad) and I've found every other application allows
- >this to me used.
- >
- >Also, isn't it alt-c that cancels with dos, not control-c, since ascii is
- >used with dos also?
-
- No, its control-c, and therein lies the rub. If a (reformed) DOS user
- tries to use control-c to cancel a Mac dialog (old habits do die hard),
- the program will almost always interpret that as a keypad enter, and act
- as if the OK button was hit.
-
- To be honest, I've never actually seen a user get bit by this. The way
- we found it was that we have some testing monkeys who, while hitting
- random keys in an effort to produce a Shakespeare sonnet, hit control-c
- while a dialog was displayed and were startled by the effect.
-
- FWIW: control-c maps to ASCII 3, which is the ETX character. I'm reasonably
- sure that ETX stands for "end transmission". This (mostly reformed)
- programmer has to admit it makes more sense to interpret this as OK
- rather than cancel, especially since control-x is the ASCII CAN character,
- which I'm reasonably sure is short for "cancel". But control-c had a
- long tradition of meaning "cancel" (or perhaps, more correctly, "stop") in
- old DEC systems (RSTS, VMS, and probably RT-11), and that is probably why
- it was adopted for MS-DOS. (Also, CP/M may have used control-c for that
- purpose. Its been awhile. Have I given away my age yet?)
-
-
-
- ---------------------------
-
- >From quinlan@news.sfu.ca (Brian Quinlan)
- Subject: PPC ProcPtr functions?
- Date: 13 Oct 1995 20:52:36 GMT
- Organization: Simon Fraser University
-
- In my program I use, like everyone else, a handler in my TrackControl
- call for my scrollbars. However, when I compile my program for PPC
- this produces a crash. That makes sense but how do I fix it?
-
- --
-
- Brian Quinlan
- quinlan@sfu.ca
-
- +++++++++++++++++++++++++++
-
- >From Darren Giles <mars@netcom.com>
- Date: Sun, 15 Oct 1995 19:40:00 GMT
- Organization: NETCOM On-line Communication Services (408 261-4700 guest)
-
- In article <45mjik$crr@morgoth.sfu.ca> Brian Quinlan, quinlan@news.sfu.ca
- writes:
- >In my program I use, like everyone else, a handler in my TrackControl
- >call for my scrollbars. However, when I compile my program for PPC
- >this produces a crash. That makes sense but how do I fix it?
-
-
- The short answer: you need to create a Universal Procedure Pointer
- (UPP) for any callback routines. This is quite simple:
-
- In your globals:
- ControlActionUPP gMyTrackControlRoutineUPP;
-
- In your initialization code:
- gMyTrackControlRoutineUPP= NewControlActionProc
- (MyTrackControlRoutine)
-
- When you call TrackControl:
- result= TrackControl (theControl, &thePoint,
- gMyTrackControlRoutineUPP);
-
-
- - Darren
-
- +++++++++++++++++++++++++++
-
- >From rickc@i-link.net (Richard Cardona)
- Date: 15 Oct 1995 14:19:59 GMT
- Organization: TradeWave Corporation (formerly EINet)
-
- In article <45mjik$crr@morgoth.sfu.ca>, quinlan@news.sfu.ca (Brian
- Quinlan) wrote:
-
- > In my program I use, like everyone else, a handler in my TrackControl
- > call for my scrollbars. However, when I compile my program for PPC
- > this produces a crash. That makes sense but how do I fix it?
- >
- > --
- >
- > Brian Quinlan
- > quinlan@sfu.ca
-
- Try reading Inside Macintosh : PowerPC System Software. It will explain
- all about UniversalProcPtrs and how to fix your situation. You could
- probably soak up what you need in 1 bookstore visit or go to Apple's Web
- site with Inside Mac online.
-
- Rick
-
- ---------------------------
-
- >From adam@park78.demon.co.uk (Adam Lloyd)
- Subject: Perl for Mac?
- Date: Fri, 13 Oct 1995 18:32:00 +0100
- Organization: a sluggish molehill.
-
- Are there any good implementations of Perl for the Mac, other than the Perl
- Tool for MPW? I'm thinking along the lines of something stand-alone...
-
- Adam.
-
-
-
- +++++++++++++++++++++++++++
-
- >From neeri@iis.ee.ethz.ch (Matthias Neeracher)
- Date: 16 Oct 1995 16:41:52 GMT
- Organization: Integrated Systems Laboratory, ETH, Zurich
-
- In article <ACA4612096681197B@park78.demon.co.uk>, adam@park78.demon.co.uk (Adam Lloyd) writes:
- > Are there any good implementations of Perl for the Mac, other than the Perl
- > Tool for MPW? I'm thinking along the lines of something stand-alone...
-
- ftp://ftp.switch.ch/software/mac/perl/
- ftp://ftp.share.com/pub/macperl/
-
- Matthias
-
- - ---
- Matthias Neeracher <neeri@iis.ee.ethz.ch> http://err.ethz.ch/members/neeri.html
- "One fine day in my odd past..." -- Pixies, _Planet of Sound_
-
- +++++++++++++++++++++++++++
-
- >From Gordon Tillman <got@mindspring.com>
- Date: 15 Oct 1995 14:07:55 GMT
- Organization: n/a
-
- Hi Adam,
-
- In article <ACA4612096681197B@park78.demon.co.uk> Adam Lloyd,
- adam@park78.demon.co.uk writes:
- >Are there any good implementations of Perl for the Mac, other than the
- Perl
- >Tool for MPW? I'm thinking along the lines of something stand-alone...
-
-
- You can use MacPerl. It's been a while since I got it, so there is
- probably a newer version around. I have version 4.1.3, Patchlevel 36.
-
- In the about box it said the Mac version was written by:
-
- Matthias Neeracher neeri@iis.e.ethz.ch
- Tim Endres time@ice.com
-
- You can probably find it at the usual Mac archives. If you cannot, let
- me know and I will see if I can help. This version does not require MPW.
-
- --gordon tillman
- - ----------------------------------------------------------------------
- Internet: got@mindspring.com | Voice: 615-238-6506
- gordyt@aol.com | Fax: 615-238-4924
- America Online: GordyT |US Mail: 7312 Flagstone Drive
- CompuServe: 74372,1071 | Ooltewah, TN 37363
- - ----------------------------------------------------------------------
-
- ---------------------------
-
- >From hellstrm@jaguNET.com (Ben Hellstrom)
- Subject: Popup Menus in 9-pt geneva ?????
- Date: Tue, 03 Oct 1995 20:27:46 -0400
- Organization: jaguNET Access Services
-
- Many of the utilities I have have nice little popups in 9-pt geneva. They
- dont have MDEFs (which means the MDEFs are either embedded in other code
- resources or they are using the standard MDEF).
-
- Can anyone give me a clue as to how to produce a menu in 9-point geneva?
- Do I have to switch the system font? If so, how?
-
-
- TIA
-
- --
- Ben Hellstrom
- hellstrm@jaguNET.com
-
- +++++++++++++++++++++++++++
-
- >From tim@dierks.org (Tim Dierks)
- Date: Wed, 04 Oct 1995 00:35:56 -0700
- Organization: Best Internet Communications
-
- In article <hellstrm-0310952027460001@brian.jagunet.com>,
- hellstrm@jaguNET.com (Ben Hellstrom) wrote:
-
- >Many of the utilities I have have nice little popups in 9-pt geneva. They
- >dont have MDEFs (which means the MDEFs are either embedded in other code
- >resources or they are using the standard MDEF).
- >
- >Can anyone give me a clue as to how to produce a menu in 9-point geneva?
- >Do I have to switch the system font? If so, how?
-
- Mmmm.... Code (including way-cool trap patches!)
-
- Setting the width will need to be fixed to use a UPP for native
- applications. Or, just hack it out. It's sick anyway. Unpatching traps?! Yuk.
-
- - Tim.
-
- Note: I tried to keep this from being wrapped.
-
- // Call just like PopUpMenuSelect, only you can set the font, size, and
- width of the popup menu.
- // Pass 0 for font, size, or width to use the defaults.
- long
- PopUpMenuSelectWithFontAndWidth(MenuHandle menu,short top,short left,short
- popUpItem,short font,short size,short width)
- { long menuChoice; // Stores the
- chosen menu & item
- short saveSysFontFam,saveSysFontSize; // Room for saving
- the current system font and size
- GrafPtr wMgrPort; // Pointer to the
- window manager port
- CalcMenuSizeProc oldCalcMenuSize; // Address of the
- old CalcMenuSize procedure
-
- // First, we'll clean up after buggy software. A number of commercial
- products
- // (word processors are most common) screw up the window manager port;
- they leave the
- // txSize field set to 12. It and the txFont field should always be
- left set to 0;
- // this makes them the system font and size. So first thing we do is
- clean up
- // after these miscreants.
-
- GetWMgrPort(&wMgrPort);
- SetPort(wMgrPort);
- TextFont(0);
- TextSize(0);
-
- // Now, if we're going to change the font or the size, then we
- remember the old
- // system font and size so they can be restored later
-
- if (font != 0 || size != 0)
- { saveSysFontFam = *(short*)SysFontFam;
- saveSysFontSize = *(short*)SysFontSize;
-
- if (font != 0)
- *(short*)SysFontFam = font;
- if (size != 0)
- *(short*)SysFontSize = size;
-
- *(long*)LastSPExtra = -1; // This forces the system to
- recognize our changes
- }
-
- // Now we need to set the width. Unfortunately, it's not as easy as
- changing the
- // font and size; we need to patch CalcMenuSize so we can fake the
- width of the menu
- if (width != 0)
- { oldCalcMenuSize = (CalcMenuSizeProc)NGetTrapAddress(0x148,ToolTrap);
-
- gCMSParms.oldCMS = oldCalcMenuSize;
- gCMSParms.theMenu = menu;
- gCMSParms.width = width;
-
- NSetTrapAddress((long)CalcMenuSizePatch,0x148,ToolTrap);
-
- // Now we should zero out the menu's stored width and height to
- ensure that
- // its size will be recalculated
-
- (**menu).menuWidth = 0;
- (**menu).menuHeight = 0;
- }
-
- menuChoice = PopUpMenuSelect(menu,top,left,popUpItem);
-
- // Now we restore the original CalcMenuSize if we changed it
- if (width != 0)
- NSetTrapAddress((long)oldCalcMenuSize,0x148,ToolTrap);
-
- // Now we restore the original font and size to their places
- // if we changed them
- if (font != 0 || size != 0)
- { *(short*)SysFontFam = saveSysFontFam;
- *(short*)SysFontSize = saveSysFontSize;
- *(long*)LastSPExtra = -1;
- }
-
- // return the chosen menu & item
- return menuChoice;
- }
-
- // This is the patch to CalcMenuSize; first, we call the original
- // to calculate the size. If the menu being calculated is ours,
- // we then change the width to our stored width. Note that this
- // is a tail patch; while still frowned upon, these are not as
- // bad as they used to be, and it's really the best way to
- // accomplish our task.
- //
- // Our use of a global to store the original CalcMenuSize and
- // other data implies we'll be sure that A5 hasn't been changed;
- // we can be fairly certain this is true in this particular
- // case.
-
- static pascal void
- CalcMenuSizePatch(MenuHandle theMenu)
- {
- gCMSParms.oldCMS(theMenu); // Call the original CalcMenuSize();
-
- if (theMenu == gCMSParms.theMenu) // If it's our menu, fix up the width
- (**theMenu).menuWidth = gCMSParms.width;
- }
-
- --
- Tim Dierks - Software Haruspex - tim@dierks.org
- If you can't lick 'em, stick 'em on with a big piece of tape. - Negativland
-
- +++++++++++++++++++++++++++
-
- >From Richard Wesley <hawkfish@punchdeck.com>
- Date: 4 Oct 1995 14:42:41 GMT
- Organization: Punch Deck Consulting
-
- hellstrm@jaguNET.com (Ben Hellstrom) wrote:
- >Many of the utilities I have have nice little popups in 9-pt geneva. They
- >dont have MDEFs (which means the MDEFs are either embedded in other code
- >resources or they are using the standard MDEF).
- >
- >Can anyone give me a clue as to how to produce a menu in 9-point geneva?
- >Do I have to switch the system font? If so, how?
-
- If you are using PowerPlant and Constructor, just set the text traits of
- the popup control to geneva-9.
-
- If you are doing this from scratch, then what you need to do is:
-
- 1) make the current port the window that you want to add the control to;
- 2) set the font to geneva-9
- 3) make sure that the controlKind has kControlUsesOwningWindowsFontVariant;
- 4) instantiate the control.
-
- No trap patching should be required.
-
- - rmgw
-
- http://www.punchdeck.com/hawkfish/PunchDeck.html
-
- - --------------------------------------------------------------------------
- Richard Wesley hawkfish@punchdeck.com | "What was that popping sound?"
- Punch Deck Consulting pnchdeck@aol.com | "A paradigm shifting without a
- Macintosh Software Development | clutch." - Dilbert (Scott Adams)
- - --------------------------------------------------------------------------
-
-
-
- +++++++++++++++++++++++++++
-
- >From jeremyr@dcs.qmw.ac.uk (Jeremy Roussak)
- Date: 4 Oct 1995 19:45:07 GMT
- Organization: Queen Mary & Westfield College, London, England
-
- In article <hellstrm-0310952027460001@brian.jagunet.com>
- hellstrm@jaguNET.com (Ben Hellstrom) writes:
-
- > Many of the utilities I have have nice little popups in 9-pt geneva. They
- > dont have MDEFs (which means the MDEFs are either embedded in other code
- > resources or they are using the standard MDEF).
- >
- > Can anyone give me a clue as to how to produce a menu in 9-point geneva?
- > Do I have to switch the system font? If so, how?
-
- Use the Popup CDEF with the "use window font" bit set and set the font
- to 9 point Geneva.
-
- Jeremy
-
- +++++++++++++++++++++++++++
-
- >From jbruni@primenet.com (Joseph Bruni)
- Date: Wed, 04 Oct 1995 23:21:58 -0700
- Organization: Primenet
-
- In article <hellstrm-0310952027460001@brian.jagunet.com>,
- hellstrm@jaguNET.com (Ben Hellstrom) wrote:
-
- > Many of the utilities I have have nice little popups in 9-pt geneva. They
- > dont have MDEFs (which means the MDEFs are either embedded in other code
- > resources or they are using the standard MDEF).
- >
- > Can anyone give me a clue as to how to produce a menu in 9-point geneva?
- > Do I have to switch the system font? If so, how?
-
- Use the control manager to do the popup for you. Just make sure you use
- the "useWFont" variant.
-
- +++++++++++++++++++++++++++
-
- >From <brick@spirit.com.au>
- Date: 6 Oct 1995 07:42:08 GMT
- Organization: Spirit Networks
-
- hellstrm@jaguNET.com (Ben Hellstrom) wrote:
-
- >Many of the utilities I have have nice little popups in 9-pt geneva. >They dont have MDEFs (which means the MDEFs are either embed=
- ded in
- >other code resources or they are using the standard MDEF).
- >
- >Can anyone give me a clue as to how to produce a menu in 9-point
- >geneva? Do I have to switch the system font? If so, how?
-
- Ben,
-
- As you know, to create a control that uses the standard pop-up control
- definition function, you specify the popupMenuProc constant in the
- procID field of the resource description for the control.
-
- If you add the constant useWFont to popupMenuProc, the pop-up title
- and menu item text will be drawn in the graphics port's current font
- rather than the system font. So all you have to do then is set your
- graphics port font and size to Geneva 9 point and you will
- get what you want.
-
- K. J. Bricknell
- Canberra
- Australia
-
-
- +++++++++++++++++++++++++++
-
- >From Kenn@owl-uk.co.uk (Ken Nicolson)
- Date: Fri, 13 Oct 1995 10:22:33 GMT
- Organization: Office Workstations Limited
-
- hellstrm@jaguNET.com (Ben Hellstrom) wrote:
-
- >Many of the utilities I have have nice little popups in 9-pt geneva. They
- >dont have MDEFs (which means the MDEFs are either embedded in other code
- >resources or they are using the standard MDEF).
-
- >Can anyone give me a clue as to how to produce a menu in 9-point geneva?
- >Do I have to switch the system font? If so, how?
-
- Here's the solution I came up with. Pass in the menu handle, position
- and font number and size, and get returned the string of the menu
- option, or -1 if no selection.
-
- I assume Color QuickDraw, but it seems to work even if I switch my
- monitor to monochrome.
-
- The code was written after reading the TechNote TB-550, Menu Managers
- Q&A. Apparently, this is how the Popup Control gadget does its stuff.
-
- Maybe a routine like this should go into a FAQ somewhere, as it seems
- a common thing to want to do, but how to do it is deeply buried on the
- developer CDs.
-
- int PopUpMenuSelectWithFont(MenuHandle hMenu,
- int x, int y,
- short txFont, short txSize,
- char *szValue)
- {
- SInt32 lPopUpResult;
- int nPos;
- SInt16 saveFamily;
- SInt16 saveSize;
- SInt32 saveLastSP;
- CGrafPtr wmPort;
- GrafPtr currentPort;
-
- // Save current viewport
- GetPort( ¤tPort );
-
- // Save current system default fonts
- saveFamily = LMGetSysFontFam();
- saveSize = LMGetSysFontSize();
- saveLastSP = LMGetLastSPExtra();
-
- GetCWMgrPort( &wmPort );
-
- SetPort( (GrafPtr) wmPort );
-
- TextSize( txSize );
-
- // Install temporary font as system font
- LMSetSysFontFam( txFont );
- LMSetSysFontSize( txSize );
- LMSetLastSPExtra( (SInt32) -1 );
-
- // Process the pop-up menu
- lPopUpResult = PopUpMenuSelect( hMenu, y, x, 1 );
-
- // Restore port
- SetPort( currentPort );
-
- // Restore system default fonts
- LMSetSysFontFam( saveFamily );
- LMSetSysFontSize( saveSize );
- LMSetLastSPExtra( saveLastSP );
-
- if (HIWORD(lPopUpResult) != 0)
- {
- nPos = LOWORD( lPopUpResult );
- getitem( hMenu, nPos, pszValue );
- }
- else
- nPos = -1;
-
- return nPos;
- }
-
- The LMGet/LMSet functions are from CodeWarrior's LowMem.h to hide the
- access to system variables.
-
- Hope the types are correct - we have a set of #defines to hide a lot
- of Mac specifics, so I've used the base definitions from memory.
-
- Ken
-
-
- ---------------------------
-
- >From daf@bbn.com (David Fagan)
- Subject: Q: using OSAExecute to singlestep AppleScript
- Date: Tue, 10 Oct 1995 01:35:41 -0400
- Organization: BBN Educational Technologies
-
- My application would like to execute one line of AppleScript at a time.
- The lines originate as text, so I call OSACompileExecute. Unfortunately,
- the AppleScript interpreter wants entire scripts or handlers at a time, so
- if I pass a line such as,
-
- tell application "Scriptable Text Editor"
-
- I get back the error you'd expect if you tried to run the above out of the
- script editor, namely, "Expecting end tell..."
-
- Anyone have an idea to pass the interpreter one line at a time?
-
- I suppose it has something to do with the contextID parameter to
- OSACompileExecute, but nothing I've done with it helps, and IM Scripting
- doesn't provide any clues that I can see.
-
- Thanks
-
- David Fagan
- daf@bbn.com
-
- +++++++++++++++++++++++++++
-
- >From jonpugh@netcom.com (Jon Pugh)
- Date: Fri, 13 Oct 1995 22:15:04 GMT
- Organization: Will hack for food
-
- David Fagan (daf@bbn.com) wrote:
- > My application would like to execute one line of AppleScript at a time.
- > The lines originate as text, so I call OSACompileExecute. Unfortunately,
- > the AppleScript interpreter wants entire scripts or handlers at a time, so
- > if I pass a line such as,
-
- > tell application "Scriptable Text Editor"
-
- > I get back the error you'd expect if you tried to run the above out of the
- > script editor, namely, "Expecting end tell..."
-
- > Anyone have an idea to pass the interpreter one line at a time?
-
- You can't do this. There is no AppleScript support for single stepping.
-
- I spoke with the DTS folks helping you and we discussed a possible solution,
- but not knowing what you are trying to do makes us unable to determine if
- this will work for what you are trying to do.
-
- Basically, you can do what the script debugging editors do. That's to use
- the OSASendProc to pause before and/or after each Apple event. Given this
- procedure, which is simply a wrapper for AESend which AppleScript calls
- instead of calling AESend, you can decide when and/or if to actually send
- the events. As I stated before though, not knowing what you are trying
- to accomplish means that I don't know if this will suffice.
-
- Jon
-
-
- ---------------------------
-
- >From samny@nyc.pipeline.com (Ed Samuels)
- Subject: Reading Notification Manager queue?
- Date: 9 Oct 1995 22:54:23 -0400
- Organization: The Pipeline
-
- Is there any way to look into the queue of the Notification Manager? I
- would like to be able to take a notification request that is generated by
- another application off of the queue. IM only describes the NMInstall and
- NMRemove functions, both of which require that you already have a pointer
- to the notification request. It makes no reference to any other NM
- routines, and it seems to imply that there are no others!
-
- Most of the other OS routines have some function that returns a pointer
- to the bottom of the queue, but apparently the Notification Manager
- doesn't. I can't even find a low-memory global that points to it! If there
- isn't an easier way, I think I'll have to patch the routine to find out
- what is going on. That is something that I DO NOT want to do--NMInstall
- preserves most registers and does not move memory, so such a patch would be
- very shaky, and definitely much too complicated for my purposes.
-
- If anyone can direct me to any info about the Notification Manager that
- describes more than what is said in Inside Macintosh, thanks. :)
- ___________________________________
- Richard Samuels
- samny@nyc.pipeline.com
-
- +++++++++++++++++++++++++++
-
- >From brians@pbcomputing.com (Brian Stern)
- Date: 14 Oct 1995 03:37:16 GMT
- Organization: The University of Texas at Austin, Austin, Texas
-
- Richard,
-
- The OS queue used by the Notification Manager is undocumented. An earlier
- version of Macsbug used to know about the lowmem global, but the current
- version seems to have forgotten its name :-/ A quick look at NMInstall
- shows a suspicious check to location 0x0DD5.
-
- I have an INIT that patches NMInstall and keeps track of the records that
- are posted. As I was developing this I first walked the queue but in the
- end decided that since it was undocumented I would do it another way. You
- can be sure things won't change before Copland anyway. Not all requests
- that are added to the queue are removed by the Notification manager.
- There is a flags field in each NMRecord and apparently once a Notification
- is shown a bit is set so that the notification isn't shown again.
-
- Good luck,
-
- Brian }:-{)}
-
- In article <45cn8v$1ek@pipe4.nyc.pipeline.com>, samny@nyc.pipeline.com (Ed
- Samuels) wrote:
-
- <Is there any way to look into the queue of the Notification Manager? I
- <would like to be able to take a notification request that is generated by
- <another application off of the queue. IM only describes the NMInstall and
- <NMRemove functions, both of which require that you already have a pointer
- <to the notification request. It makes no reference to any other NM
- <routines, and it seems to imply that there are no others!
- <
- < Most of the other OS routines have some function that returns a pointer
- <to the bottom of the queue, but apparently the Notification Manager
- <doesn't. I can't even find a low-memory global that points to it! If there
- <isn't an easier way, I think I'll have to patch the routine to find out
- <what is going on. That is something that I DO NOT want to do--NMInstall
- <preserves most registers and does not move memory, so such a patch would be
- <very shaky, and definitely much too complicated for my purposes.
- <
- < If anyone can direct me to any info about the Notification Manager that
- <describes more than what is said in Inside Macintosh, thanks. :)
- <___________________________________
- <Richard Samuels
- <samny@nyc.pipeline.com
-
- ____________________________________________________________________
- Brian Stern {;-{)} Toolbox commando and Menu bard Stern@metrowerks.com BrianS@pbcomputing.com
- INIT Writing FAQ etc. at <ftp://ftp.pbcomputing.com//Guests/BrianS/>
-
- ---------------------------
-
- End of C.S.M.P. Digest
- **********************
-